package happywing.server;

import happywing.server.exceptions.DependException;
import happywing.server.exceptions.InvalidTimeException;

import java.util.Date;
import java.util.List;

public class Task implements DBProxyAble {
	private Date startDate;
	private Date endDate;
	
	private Task parentTask;
	private List<Task> depends;
	private List<Task> childTasks;
	
	
	public Date getStartDate(){
		return startDate;
	}
	public Date getEndDate(){
		return endDate;
	}
	public Task getParent(){
		return parentTask;
	}
	
	
	public void setParentPlan(Task task,Integer priority,List<Task> depends) throws DependException,InvalidTimeException{
		if (parentTask.getStartDate().after(task.getStartDate())||task.getEndDate().after(parentTask.getEndDate())) {
			throw new InvalidTimeException();
		}
		if (!checkDepends(depends)) {
			throw new DependException();
		}
    	parentTask=task;
	}
	public List<Task> listChildIPlans(){
		return childTasks;
	}
	
	
	
	@Override
	public boolean DBIsLoaded() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void DBLoad() {
		// TODO Auto-generated method stub

	}

	@Override
	public void DBSave() {
		// TODO Auto-generated method stub

	}

	@Override
	public void DBDelete() {
		// TODO Auto-generated method stub

	}
	
	private boolean checkDepends(List<Task> depends) {
		//TODO 检查依赖是否正确
		return false;
	}

}
